<?php
namespace application\datatypes;
use application\datatypes\FileUploadBase;
class MusicPlayer extends FileUploadBase {
	public static $name = 'Music Player';
	public static $fields = array();	
	public static $filters = "'audio/mp3', 'audio/wav'";
	public static $maxSize = '1mb';
	
	public static function onUpload($field) {

	}
	
	public static function displayHeader($field = null) {
		//Modulator()->includeScript('swfobject');
		?>
		<script type="text/javascript" src="<?=getCommonFile('third-party/dewplayer/swfobject.js')?>"></script>
		<?php

	}
	
	public static function formHeader($field) {
		parent::uploadJS($field);

	}
	
	public static function buildExisting($file) {
		return $file;
	}
	
	public static function prepareData($field, $data, $params) {
		$songs = $data[$field->cf_column];
		if(count($songs)) {
			$path = array();
			foreach($songs as $song) {
				$location = DB()->getVar("SELECT `upload_filename` FROM `cn_uploads` WHERE `upload_id`='$song'");
				$path[] = CN_URL.'uploads/'.$location;
			}
			$path = implode('|', $path);
			?>
			<object type="application/x-shockwave-flash" data="<?=getCommonFile('third-party/dewplayer/dewplayer-rect.swf')?>?mp3=<?=$path?>" width="240" height="20" id="dewplayer-rect"><param name="wmode" value="transparent" /><param name="movie" value="<?=getCommonFile('third-party/dewplayer/dewplayer-rect.swf')?>&mp3=<?=$path?>" /></object>

				<?php
		}
	}
			
	

}
?>